package com.taobao.tools;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class WindowTaskList {

	public static boolean findProcess(String processName) {
		boolean exist = false;
		BufferedReader bufferedReader = null;
		try {
			Process proc = Runtime.getRuntime().exec("tasklist /FI \"IMAGENAME eq " + processName + "\"");
			bufferedReader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
			String line = null;
			while ((line = bufferedReader.readLine()) != null) {
				if (line.contains(processName)) {
					exist = true;
					break;
				}
			}
		} catch (Exception ex) {
			exist = true;
		} finally {
			if (bufferedReader != null) {
				try {
					bufferedReader.close();
				} catch (Exception ex) {
				}
			}
		}
		return exist;
	}
}
